<?php 
class subscribe_admin extends MX_Controller{
	public function index(){
		
	}
	public function addmail($mail=''){
		$mails=array();
		if(empty($mail)){
			$mails=explode(',',$this->input->post('email'));
			
		}
		if(!empty($mails)){
			$this->load->helper('email');
			foreach ($mails as $mail){
				if (valid_email($mail))
					$this->model()->add($mail);
			}
			
		}
		$this->load->helper('url');
		redirect($this->input->post('redirect'), 'refresh');
	}

	public function listmail($isPage=0,$per_page=20){
		$this->load->library('pagination');
		$config['base_url'] = $this->config->config['base_url'].'newsletter/admin/index/pageMail/';
		$config['total_rows'] = $this->model()->totalEmail();
		$config['per_page'] = $per_page;
		
		$this->pagination->initialize($config);
		
		$data['emails'] = $this->model()->get_emails($isPage,$config['per_page']) ;
		$data['page']	= $this->pagination->create_links();
		
		return $data;
	}
}